package ar.com.ford.it.fullEconomics.logic;

import java.util.Collection;
import org.apache.commons.lang.StringUtils;
import ar.com.ford.it.fullEconomics.persistence.dao.WSLSecurityDao;
import ar.com.ford.it.fullEconomics.persistence.dto.Tms0005AccprofVw;
import ar.com.ford.it.fullEconomics.persistence.dto.Tms0008UsrprofVw;

public class WSLSecurityLogic {

    public Collection<Tms0005AccprofVw> findPermissonsByUsr(String plantCode, String profileCode,
            String systemCode) {
        WSLSecurityDao dao = new WSLSecurityDao();
        Tms0005AccprofVw tms0005AccprofVw = new Tms0005AccprofVw();
        Collection<Tms0005AccprofVw> ret = null;

        if (StringUtils.isEmpty(plantCode)) {
            tms0005AccprofVw.setMs0005PlantCodeC(null);
        } else {
            tms0005AccprofVw.setMs0005PlantCodeC(plantCode);
        }

        if (StringUtils.isEmpty(profileCode)) {
            tms0005AccprofVw.setMs0005ProfileCodeC(null);
        } else {
            tms0005AccprofVw.setMs0005ProfileCodeC(profileCode);
        }

        if (StringUtils.isEmpty(systemCode)) {
            tms0005AccprofVw.setMs0005SystemCodeC(null);
        } else {
            tms0005AccprofVw.setMs0005SystemCodeC(systemCode);
        }

        ret = dao.findPermissonsByUsr(tms0005AccprofVw);
        return ret;
    }
    
    public Collection<Tms0008UsrprofVw> findUsr(String cdsid, String systemCode) {
        WSLSecurityDao dao = new WSLSecurityDao();
        Tms0008UsrprofVw tms0008UsrprofVw = new Tms0008UsrprofVw();
        Collection<Tms0008UsrprofVw> ret = null;

        if (StringUtils.isEmpty(cdsid)) {
            tms0008UsrprofVw.setMs0008UserCodeC(null);
        } else {
            tms0008UsrprofVw.setMs0008UserCodeC(cdsid);
        }

        if (StringUtils.isEmpty(systemCode)) {
            tms0008UsrprofVw.setMs0008SystemCodeC(null);
        } else {
            tms0008UsrprofVw.setMs0008SystemCodeC(systemCode);
        }

        ret = dao.findUsr(tms0008UsrprofVw);
        return ret;
    }

}
